import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:imperius_insights/modules/scope/screen_department.dart'
    as Department;
import 'package:imperius_insights/modules/scope/screen_humans.dart' as Humans;
import 'package:imperius_insights/modules/skeleton/screen.dart' as Skeleton;
import 'package:imperius_insights/modules/projects/screen_tasks_calendar.dart' as ProjectsCalendar;
import 'package:imperius_insights/modules/quality/pmo/screen.dart'
    as PmoQuality;
import 'package:imperius_insights/portal/diagnostic/widgets.dart';

import 'paths.dart';

typedef ScreenCreator = Widget Function(
    BuildContext context, Map<String, List<String>> params);

final createHandler = <TParams>(ScreenCreator creator) => Handler(
        handlerFunc: (BuildContext context, Map<String, List<String>> params) {
      return creator(context, params);
    });

void configureRouter(Router router) {
  router.notFoundHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    print('ROUTE WAS NOT FOUND...$params');
    //    return Text('ROUTE WAS NOT FOUND...$params');
    return Skeleton.Screen();
  });
  router.define(Paths.root,
      handler: createHandler((context, params) => Skeleton.Screen()));
  router.define(Paths.projectsCalendar,
      handler: createHandler((context, params) => ProjectsCalendar.Screen()));
  router.define(Paths.scopeDepartments,
      handler: createHandler((context, params) => Department.Screen()));
  router.define(Paths.scopeHumans,
      handler: createHandler((context, params) => Humans.Screen()));
  router.define(Paths.projectQuality,
      handler: createHandler((context, params) => DiagnosticScreen()));
  router.define(Paths.pmoQuality, handler: createHandler((context, params) {
    return PmoQuality.Screen(pmo: params["pmo"][0]);
  }));
  router.define(Paths.diagnostic,
      handler: createHandler((context, params) => DiagnosticScreen()));
}
